home *** CD-ROM | disk | FTP | other *** search
/ Aminet 25 / Aminet 25 (1998)(GTI - Schatztruhe)[!][Jun 1998].iso / Aminet / dev / amos / AMOS0398.lzh / AMOSLIST / 000181_amos-request@svcs1.digex.net_Fri Mar 20 03:44:32 1998.msg < prev    next >
Text File  |  1998-04-01  |  5KB  |  166 lines

  1. >From amos-request@svcs1.digex.net  Fri Mar 20 03:44:31 1998
  2. Received: from svcs1.digex.net (svcs1.digex.net [204.91.197.224])
  3.     by pony-1.mail.digex.net (8.8.8/8.8.8) with ESMTP id DAA17373
  4.     for <mcox@access.digex.net>; Fri, 20 Mar 1998 03:44:31 GMT
  5. Received: (from daemon@localhost)
  6.     by svcs1.digex.net (8.8.5/8.8.5) id SAA29568
  7.     for amos-out; Thu, 19 Mar 1998 18:18:39 -0500 (EST)
  8. Received: from pony-2.mail.digex.net (pony-2.mail.digex.net [204.91.241.6])
  9.     by svcs1.digex.net (8.8.5/8.8.5) with ESMTP id SAA29565
  10.     for <amos-list@svcs1.digex.net>; Thu, 19 Mar 1998 18:18:39 -0500 (EST)
  11. Received: from post.mail.demon.net (post-20.mail.demon.net [194.217.242.27])
  12.     by pony-2.mail.digex.net (8.8.8/8.8.8) with SMTP id SAA08133
  13.     for <amos-list@access.digex.net>; Thu, 19 Mar 1998 18:18:37 -0500 (EST)
  14. Received: from agasinc.demon.co.uk ([193.237.4.98]) by post.mail.demon.net
  15.            id af2004235; 19 Mar 98 23:17 GMT
  16. From: Andy Gibson <andy@agasinc.demon.co.uk>
  17. To: Amos List <amos-list@access.digex.net>
  18. Date: Thu, 19 Mar 1998 00:42:36 -0000
  19. Message-ID: <yam7382.1809.2015119832@post.demon.co.uk>
  20. In-Reply-To: <664.381T895T8483212@bahnhof.se>
  21. X-Mailer: YAM 1.3.4 [020] - Amiga Mailer by Marcel Beck
  22. Organization: AGAS Productions
  23. Subject: Re: Ooops! Textfile parsing
  24. MIME-Version: 1.0
  25. Content-Type: text/plain
  26. Status: O
  27. X-Status: 
  28.  
  29. On Wednesday 18-Mar-98 at 13:08:17, a nutter named Jonas Thorell
  30. had wet pants when they typed about `Re: Textfile parsing'.
  31.  
  32. >Thanks for the example. It doesn't quite work but I'll see if I can work out
  33. >what's going on. When I enter s:startup-sequence as input-file I just get the
  34. >first line of it for some reason.
  35.  
  36. Ooops!  I made a slight error in the code. Well, I was typing it up as
  37. an example. Anyway, here is what it should be like. Hope this helps...
  38.  
  39. <SNIP>
  40. '
  41. ' ***************************************
  42. '
  43. ' Load and process a text file easily :) 
  44. ' bY Andy Gibson 
  45. '
  46. ' I hope this helps you out Jonas....
  47. ' Sorry about the last one! This one's
  48. ' fine though :-)
  49. '
  50. ' ***************************************
  51. '
  52. ' Depending on the size of your file, you may need to UP this value... 
  53. Set Buffer 40
  54. '
  55. ' LINES must be global here... 
  56. Global TXT$,LINES
  57. '
  58. ' Enter your text file's full path here... 
  59. Proc _LOAD_TXT["hd2:text/Letter.asc"]
  60. '
  61. '
  62. ' Now we can use a Dim with the correct amount of lines to hold
  63. ' each line in there...
  64. Dim TXT$(LINES)
  65. Global TXT$()
  66. '
  67. ' Simply sort the lines into the Global Dim here...
  68. Proc _SORT_FILE
  69. '
  70. '
  71. ' Now you can easily read any line of the text held in the array 
  72. ' TXT$().
  73. '
  74. ' eg. Print first 10 lines of text file... 
  75. For _DISPLAY=0 To 10
  76. Print TXT$(_DISPLAY)
  77. Next _DISPLAY
  78. Edit 
  79. '
  80. '
  81. '
  82. ' Procedure are here...
  83. '
  84. Procedure _LOAD_TXT[TXT$]
  85.    '
  86.    ' This Proc will work out how many lines are in your file. 
  87.    ' Checks for normal Chr$(10) RETURN code. You could alter
  88.    ' it to Chr$(13) for PC text files if need be....
  89.    '
  90.    ' Amcaf only.... (no need to use Open in etc...) 
  91.    ' Dload TXT$,17  
  92.    '
  93.    '
  94.    ' Amos normal way... 
  95.    Open In 1,TXT$
  96.    L=Lof(1) : Close 1
  97.    Reserve As Data 7,L
  98.    Bload TXT$,7
  99.    '
  100.    '
  101.    ' Read Lines...
  102.    POS=Start(7) : LINES=0
  103.    '
  104.    Do 
  105.       Exit If POS>=Bank End(7)
  106.       LINE=Hunt(POS To Bank End(7),Chr$(10))
  107.       '
  108.       ' Wanna see the text...
  109.    '   A$=Peek$(POS,POS-LINE,Chr$(10))
  110.    '   Print A$ 
  111.       '
  112.       Exit If LINE=Bank End(7) or LINE=0
  113.       POS=LINE+1
  114.       Inc LINES
  115.    Loop 
  116.    '
  117.    ' One other point to note, the Bank End command is not an normal 
  118.    ' Amos Pro one! And I can't remember which Ext I have installed
  119.    ' which uses it! If this code doesn't funtion properly in your 
  120.    ' interpreter, simply change the Bank End commands to summat 
  121.    ' more suitable like Start(bnk)+start(bnk) to Length(bnk)
  122.    '
  123. End Proc
  124. Procedure _SORT_FILE
  125.    '
  126.    ' Hold each line of text in the array...easy or what?
  127.    '
  128.    POS=Start(7)
  129.    '
  130.    For I=0 To LINES
  131.       A$=Peek$(POS,Bank End(7),Chr$(10))
  132.       If A$>""
  133.          TXT$(I)=Peek$(POS,Bank End(7),Chr$(10))
  134.          Add POS,Len(TXT$(I))+1
  135.       Else 
  136.          Inc POS
  137.       End If 
  138.    Next I
  139.    '
  140.    ' No more need to hold the file in a mem bank, so erase it...
  141.    '
  142.    Erase 7
  143.    '
  144. End Proc
  145. '
  146. <SNIP>
  147.  
  148. Once again, sorry for the slight mix-up with the last one sent! 
  149.  
  150. If you need further help, feel free to email me. I'll do my best.
  151.  
  152. Tarra. Andy Gibson
  153.  
  154.  
  155. -- 
  156. *****************************************************************
  157. *_______/\_____/\_______/\_____/\                               *
  158. *\       /\  ___/\       /\  ___/ Andy Gibson <---------------- *
  159. * \_/\  / /\/|  _ \_/\  /  \/ \   ----------> aka SKiDZ/Area 51 *
  160. * / _/ / /   |_| // _/ /  __\  \                                *
  161. * \// /  \___   / \// /  /__   /    andy@agasinc.demon.co.uk    *
  162. *  /_/       \_/   /_/      \_/      <-=-=-=-=-=-=-=-=-=->      *
  163. *         pRODUCTiONS 9T8                                       *
  164. *****************************************************************
  165.  
  166.